<?php

/**
 * Created by JetBrains PhpStorm.
 * User: GMC02
 * Date: 9/25/13
 * Time: 4:46 PM
 * To change this template use File | Settings | File Templates.
 */
class HSUrl {

    // region Common

    public static function home() {
        return Yii::app()->getBaseUrl(true);
    }

    // endregion

    public static function searchUrl() {
        return HSUrl::home() . '/tim-kiem';
    }

    // region User
    public static function login() {
        return CHtml::normalizeUrl(array('user/login'));
    }

    public static function loginOpenID($provider = 'facebook') {
        return CHtml::normalizeUrl(array('user/openid', 'provider' => $provider));
    }

    public static function logout() {
        return CHtml::normalizeUrl(array('user/logout'));
    }

    // endregion

    //region BACK-END

    public static function backendUrl() {
        return Yii::app()->BaseUrl . '/backend.php';
    }

    public static function backendDefaultUrl() {
        return HSUrl::backendUrl() . '/site/index';
    }

    public static function backendChangePasswordUrl() {
        return HSUrl::backendUrl() . '/user/changePassword';
    }

    public static function backendLoginUrl() {
        return HSUrl::backendUrl() . '/user/login';
    }

    public static function backendLogoutUrl() {
        return HSUrl::backendUrl() . '/user/logout';
    }

    public static function backendUsersUrl() {
        return HSUrl::backendUrl() . '/user/index';
    }

    public static function backendCreateUsersUrl() {
        return HSUrl::backendUrl() . '/user/create';
    }

    public static function backendUpdatePasswordUserUrl($id) {
        return HSUrl::backendUrl() . '/user/updatePassword?id=' . $id;
    }

    public static function backendCreateCompanyUrl() {
        return HSUrl::backendUrl() . '/company/create';
    }

    public static function backendCompanyUrl() {
        return HSUrl::backendUrl() . '/company/index';
    }

    public static function backendCreateCategoryUrl() {
        return HSUrl::backendUrl() . '/category/create';
    }

    public static function backendCategoryUrl() {
        return HSUrl::backendUrl() . '/category/index';
    }

    public static function publishedCommentUrl($id, $published = 1) {
        return HSUrl::backendUrl() . '/comment/published?id=' . $id . '&published=' . $published;
    }

    public static function backendCommentUrl() {
        return HSUrl::backendUrl() . '/comment/index';
    }

    public static function backendCreateCommentUrl() {
        return HSUrl::backendUrl() . '/comment/create';
    }

    public static function backendCreateAdCategoryUrl() {
        return HSUrl::backendUrl() . '/adCategory/create';
    }

    public static function backendAdCategoryUrl() {
        return HSUrl::backendUrl() . '/adCategory/index';
    }

    public static function backendCreateAdvertiseUrl() {
        return HSUrl::backendUrl() . '/advertise/create';
    }

    public static function backendAdvertiseUrl() {
        return HSUrl::backendUrl() . '/advertise/index';
    }

    public static function backendEditCompanyUrl() {
        return HSUrl::backendUrl() . '/editCompany/index';
    }

    //endregion

    public static function getUnbanUrl() {
        return HSUrl::home() . '/bo-chan';
    }

    public static function getContactUrl() {
        return HSUrl::home() . '/lien-he';
    }

    public static function getCompanyDetailUrl($id) {
        return HSUrl::home() . "/cong-ty/$id/";

    }

    public static function getCreateCompanyUrl() {
        return HSUrl::home() . "/cong-ty/tao-moi";
    }

    public static function getCreateAdsUrl() {
        return HSUrl::home() . "/rao-vat/tao-moi";
    }

    public static function getEditCompanyUrl($id, $name) {
        return HSUrl::home() . "/cong-ty/chinh-sua/$id/" . HSCommon::getSEO($name);
    }

    public static function getMapUrl($zipcode = '') {
        if (!$zipcode)
            return HSUrl::home() . "/map";
        else {
            HSUrl::home() . "/map/$zipcode";
        }
    }

}